#define _CRT_SECURE_NO_WARNINGS



//#include<bits/stdc++.h>
#include<iostream>
#include<numeric>
#include<algorithm>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int y = b * d;
        int x = a * d + c * b;
        cout << x / gcd(x, y) << " " << y / gcd(x, y) << "\n";
    }
    return 0;
}

